#define _CRT_SECURE_NO_WARNINGS 1

#define KIND 5

class ATM {
public:
    ATM()
        :money({ 0, 0, 0, 0, 0 })
        , cost({ 20, 50, 100, 200, 500 })
    {
    }

    void deposit(vector<int> banknotesCount) {
        for (int i = 0; i < KIND; i++)
        {
            money[i] += banknotesCount[i];
        }
    }

    vector<int> withdraw(int amount) {
        vector<int> res(5, 0);
        for (int i = 4; i >= 0 && amount > 0; i--)
        {
            res[i] = (amount / cost[i]);
            res[i] = min(res[i], money[i]);
            amount -= (res[i] * cost[i]);
        }
        if (amount == 0)
        {
            for (int i = 0; i < KIND; i++)
            {
                money[i] -= res[i];
            }
            return res;
        }
        else return { -1 };
    }
private:
    array<int, 5> cost;
    array<int, 5> money;
};

/**
 * Your ATM object will be instantiated and called as such:
 * ATM* obj = new ATM();
 * obj->deposit(banknotesCount);
 * vector<int> param_2 = obj->withdraw(amount);
 */